home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _FB4FBFF04F6D472EAAC1E0B66C05DF2B < prev    next >
Text File  |  2005-07-30  |  1KB  |  62 lines

  1. //copies model coord to tex coord 1
  2. //does 1 simple directional light
  3. //applies vertex diffuse colors and texture sampling
  4. //Luke Lenhart
  5. //(C)2004-2005 Digipen Institute of Technology
  6.  
  7. //directional light
  8. float4 lgtDirection;
  9. //float4 lgtDiffuse;
  10. float4 lgtAmbient;
  11.  
  12. //tint color
  13. float4 tint;
  14.  
  15. //world,view,projection transform
  16. float4x4 matWorldViewProj;
  17. float4x4 matWorld;
  18.  
  19. //shader input
  20. struct VS_INPUT
  21. {
  22.     float4 Pos : POSITION;
  23.     float4 Normal : NORMAL;
  24.     float2 Tex0 : TEXCOORD0;
  25.     float4 Clr : COLOR0;
  26. };
  27.  
  28. //shader output
  29. struct VS_OUTPUT
  30. {
  31.     float4 Pos0 : POSITION;
  32.     float4 Pos1 : TEXCOORD1;
  33.     float2 Tex0 : TEXCOORD0;
  34.     float4 Clr : COLOR0;
  35. };
  36.  
  37. //shader code
  38. VS_OUTPUT VShader(VS_INPUT In)
  39. {
  40.     VS_OUTPUT Out;
  41.     
  42.     //copy tex coord
  43.     Out.Tex0=In.Tex0;
  44.     
  45.     //calc transformed position
  46.     Out.Pos0=mul(matWorldViewProj,In.Pos);
  47.     Out.Pos1=mul(matWorld,In.Pos);
  48.     
  49.     //calc directional light color
  50.     float3 norm=mul(matWorld,In.Normal.xyz);
  51.     //Out.Clr.xyz=dot(norm,lgtDirection)*lgtDiffuse.xyz + lgtAmbient.xyz;
  52.     Out.Clr.a=1.0f;
  53.     //Out.Clr*=In.Clr;
  54.     
  55.     //tint color
  56.     //Out.Clr*=1-tint;    
  57.     Out.Clr.xyz=dot(norm,lgtDirection)*tint.xyz + lgtAmbient.xyz;
  58.         
  59.     //spit out the results
  60.     return Out;
  61. }
  62.